package com.cjh.lms.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cjh.lms.mapper.TClientMapper;
import com.cjh.lms.mapper.TLockEnterMapper;
import com.cjh.lms.mapper.TLockInfoMapper;
import com.cjh.lms.mapper.TLockTypeMapper;
import com.cjh.lms.mapper.TReqMapper;
import com.cjh.lms.mapper.TUserMapper;
import com.cjh.lms.mapper.business.MyMapper;
import com.cjh.lms.pojo.TClient;
import com.cjh.lms.pojo.TLockEnter;
import com.cjh.lms.pojo.TLockInfo;
import com.cjh.lms.pojo.TLockType;
import com.cjh.lms.pojo.TReq;
import com.cjh.lms.pojo.TUser;
import com.cjh.lms.pojo.business.LockEnterModel;

@Service("TestService")
public class TestService {

	@Autowired
	TLockTypeMapper tLockTypeMapper;
	@Autowired
	TLockEnterMapper tLockEnterMapper;
	@Autowired
	TLockInfoMapper tLockInfoMapper;
	@Autowired
	TUserMapper tUserMapper;
	@Autowired
	TClientMapper tClientMapper;
	@Autowired
	TReqMapper tReqMapper;
	@Autowired
	MyMapper myMapper;

	public void addUserTest(TUser tUser) {
		tUserMapper.insert(tUser);
	}

	public void addClientTeset(List<TClient> tClients) {
		for (TClient tClient : tClients) {
			tClientMapper.insert(tClient);
		}
	}

	public void addLockTypeTest(List<TLockType> tLockTypes) {
		for (TLockType tLockType : tLockTypes) {
			tLockTypeMapper.insert(tLockType);
		}
	}

	public void addEnterLock(TLockEnter tLockEnter, List<TLockInfo> tLockInfos) {
		if (tLockEnterMapper.insert(tLockEnter) > 0) {
			for (TLockInfo tLockInfo : tLockInfos) {
				tLockInfoMapper.insert(tLockInfo);
			}
		}
	}

	public void addReqTest(TReq tReq) {
		tReqMapper.insert(tReq);
	}

	public List<LockEnterModel> getEnterLock() {
		return myMapper.getLockEnter();
	}
}
